<style>
    .update_link {
        font-size: 11px; margin-left: 15px;
    }

    #trans_reversal_modal .info {
        text-transform: uppercase;
        font-weight: bold;
    }

    .updatable {
        padding: 3px 5px;
        width: 200px;
        display: inline-block;
        margin-right: 15px;
    }

    .updatable.editing {
        border: solid #ddd 1px;
        background-color: #fff;
        border-radius: 3px;
    }
</style>

<!--<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <a class="brand" href="#">
            <?php /*echo $this->Html->image('app/logo_sm.png', array('height' => '24')); */?>
        </a>

        <form class="navbar-form pull-left" action="<?php /*echo $this->Html->url(array('action' => 'search')); */?>" method="post">
            <div class="input-append">
                <input name="Student[id]" type="text" class="input-xxlarge" placeholder="Find Student By Index No." value="<?php /*echo $search_term; */?>" />
                <span class="add-on"><i class="icon-search"></i></span>
            </div>
        </form> 

        <ul class="nav pull-right">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    <i class="icon-user"></i> <b><?php /*echo $authuser['fname']; */?></b>
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="<?php /*echo $this->Html->url(array('action' => 'logout')); */?>"><i class="icon-off"></i> Sign Out</a></li>
                </ul>
            </li>
        </ul> 
    </div>
</div>-->

<div class="row-fluid">
    <div class="span6 inner_shadow" style="padding: 10px; border-right: solid 1px #ddd; min-height: 500px;">

        <h4>Search Result</h4>

        <table class="table table-hover table-bordered">
            <tr>
                <th width="25%">Student ID:</th>
                <td><?php echo $student['StudentUser']['reg_no']; ?></td>
                <td width="150" rowspan="5" class="photo" style="text-align: center; vertical-align: middle;">
                    <!--<i class="icon icon-user" style="font-size: 120px;"></i>-->
                    <?php echo $this->Html->image("/img/app/no-profile-photo.jpg", array('width' => '140')); ?>
                </td>
            </tr>

            <tr>
                <th>Name:</th>
                <td><?php echo $student['StudentUser']['fname'] . ' ' . $student['StudentUser']['lname']; ?></td>
            </tr>

            <tr>
                <th>Programme:</th>
                <td><?php echo $student['Program']['name']; ?></td>
            </tr>

            <tr>
                <th>Date of Birth:</th>
                <td><?php echo date('d-M-Y', strtotime($student['StudentUser']['date_of_birth'])); ?></td>
            </tr>

            <tr>
                <th>Gender:</th>
                <td><?php echo $student['StudentUser']['gender']; ?></td>
            </tr>

            <tr>
                <th>Mobile Number:</th>
                <td colspan="2">
                    <span class="updatable" data-url="<?php echo $this->Html->url(array('action' => 'update_profile', 'cellphone', $student['StudentUser']['id'])); ?>"><?php echo $student['StudentUser']['cellphone']; ?></span>
                    <a href="javascript:void(0);" class="update_link">&laquo; Update Number</a>
                </td>
            </tr>

            <tr>
                <th>Email Address:</th>
                <td colspan="2">
                    <span class="updatable" data-url="<?php echo $this->Html->url(array('action' => 'update_profile', 'email', $student['StudentUser']['id'])); ?>"><?php echo $student['StudentUser']['email']; ?></span>
                    <!--<a href="#" class="update_link">&laquo; Update Email</a>-->
                </td>
            </tr>

            <tr>
                <th>Current Balance:</th>
                <td colspan="2"><span id="account_balance" class="label label-success" style="padding: 7px 15px; font-weight: bold;">GHC <?php echo $student['StudentUser']['account_balance']; ?></span></td>
            </tr>
        </table>

        <div class="alert alert-info" style="display: none;">
            <a href="#" class="close" data-dismiss="alert">&times;</a>

            <h4>Contact Information Check</h4>
            <p>Please Ensure Profile Has Correct Phone Number</p>
        </div>

        <?php if ($student['StudentUser']['cellphone'] == '') { ?>
           <!-- <div class="alert alert-error">
                <a href="#" class="close" data-dismiss="alert">&times;</a>

                <h4>Contact Information Missing</h4>
                <p>Profile Does Not Have Phone Number Associated. Please collect contact information.</p>
                <p>Contact information required for notification of successful transactions</p>
            </div>-->
        <?php } ?>
    </div>

    <div id="trans_block" class="span6 inner_shadow" style="padding:10px; min-height: 500px;">

        <h4>Credit History</h4>

        <div style="margin-top: 30px;">
            <?php echo $this->element('bank/trans_table'); ?>
        </div>

        <div style="margin-top: 30px;">
            <button class="btn" id="credit_modal_btn" data-toggle="modal" data-target="#credit_modal"><i class="icon-check"></i> Credit Account</button>
        </div>
    </div>
</div>


<div class="modals">

    <div id="credit_modal" class="modal hide fade">
        <form class="form form-horizontal" method="post" action="" enctype="" style="margin: 0px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4>Credit Student Account</h4>
            </div>
            <div class="modal-body">

                <div class="control-group">
                    <label class="control-label" for="payment_method">* Payment Method</label>
                    <div class="controls">
                        <select id="payment_method" required="" name="Payee[method]">
                            <option value="">Select Type</option>
                            <option value="cash" selected="">CASH</option>
                            <option value="cheque">CHEQUE</option>
                        </select>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="amount">* Amount:</label>
                    <div class="controls">
                        <input id="amount_paid" name="Payee[amount]" type="text" value="" required="" placeholder="0.00" class="input input-mini" style="text-align: right;" />
                    </div>
                </div>

                <div class="control-group cheque_row">
                    <label class="control-label" for="cheque_number">Cheque Number:</label>
                    <div class="controls">
                        <input id="cheque_number" name="Payee[cheque_number]" type="text" value="" min="0" class="input input-small" />
                    </div>
                </div>

                <div class="control-group cheque_row">
                    <label class="control-label" for="cheque_bank">Bank:</label>
                    <div class="controls">
                        <input id="cheque_bank" name="Payee[cheque_bank]" type="text" value="" class="input" />
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="payee_name">Payee Name:</label>
                    <div class="controls">
                        <input id="payee_name" name="Payee[name]" type="text" value="" class="input" />
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="phone">Payee Phone Number:</label>
                    <div class="controls">
                        <input id="phone" name="Payee[phone]" type="text" value="" class="input input-small" />
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="address">Payee Address:</label>
                    <div class="controls">
                        <input name="Payee[address]" id="address" type="text" value="" class="input" />
                    </div>
                </div>

                <input type="hidden" name="StudentUser[id]" value="<?php echo $student['StudentUser']['id']; ?>" />

            </div>
            <div class="modal-footer">
                <button type="submit" href="<?php echo $this->Html->url(array('action' => 'credit_account')); ?>" id="credit_btn" class="btn btn-primary">Credit Account</button>
                <a href="#credit_modal" class="btn" data-toggle="modal">Close</a>
            </div>
        </form>
    </div>


    <div id="trans_reversal_modal" class="modal hide fade">
        <form class="form form-horizontal" method="post" action="<?php echo $this->Html->url(array('action' => 'revert_transaction')); ?>" enctype="" style="margin: 0px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4>Revert Credit Transaction</h4>
            </div>
            <div class="modal-body">

                <p>
                    You are about to revert the selected <span class="info" id="pay_method"></span> transaction, 
                    debit the student account by GHC <span class="info" id="amount"></span>.
                </p>

                <p>If you will like to proceed, please specify the reason for the reversal below: <br /><br /></p>

                <div class="control-group">
                    <label class="control-label" for="address">Revert Reason:</label>
                    <div class="controls">
                        <textarea name="Transaction[revert_reason]" id="revert_reason" class="input" required=""></textarea>
                    </div>
                </div>

                <input type="hidden" name="Transaction[id]" id="transaction_id" value="" />
                <input type="hidden" name="Transaction[student_user_id]" value="<?php echo $student['StudentUser']['id']; ?>" />
                <input type="hidden" name="Transaction[debit_amt]" id="transaction_debit_amt" value="" />

            </div>
            <div class="modal-footer">
                <button type="submit" href="<?php echo $this->Html->url(array('action' => 'credit_account')); ?>" id="revert_btn" class="btn btn-danger">Revert</button>
                <a href="#trans_reversal_modal" class="btn" data-toggle="modal">Close</a>
            </div>
        </form>
    </div>

    <div id="receipt_modal" class="modal hide fade">
        <form class="form form-horizontal" method="post" action="" enctype="" style="margin: 0px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4><span class="bank_name_holder"></span> - Receipt</h4>
            </div>
            <div class="modal-body">

                <div class="control-group">
                    <label class="control-label" for="payment_method"> Payment Method</label>
                    <div class="controls payment_method_holder">

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="amount"> Amount Credited:</label>
                    <div class="controls amount_paid_holder">

                    </div>
                </div>

                <div class="control-group cheque_row">
                    <label class="control-label" for="cheque_bank">Bank Branch:</label>
                    <div class="controls bank_branch_holder">

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="payee_name">Payee Name:</label>
                    <div class="controls payee_name_holder">

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="phone">Payee Phone Number:</label>
                    <div class="controls phone_holder">

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="address">Payee Address:</label>
                    <div class="controls address_holder">

                    </div>
                </div>
            </div>
            <div class="modal-footer">
               <!-- <button type="submit" href="<?php /*echo $this->Html->url(array('action' => 'credit_account')); */?>" id="credit_btn" class="btn btn-primary">Credit Account</button>-->
                <a href="#receipt_modal" class="btn btn-primary" data-toggle="modal">Ok</a>
            </div>
        </form>
    </div>

    <div id="message_modal" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4>Message Title</h4>
        </div>
        <div class="modal-body">
            Message Body
        </div>
        <div class="modal-footer">
            <a href="#" class="btn" data-dismiss="modal">Close</a>
        </div>
    </div>
</div>

<script type="text/javascript">
    var teller_credit_limit = <?php echo json_encode($bank_info['Bank']['teller_credit_limit']); ?>;
    var teller_serving = <?php echo json_encode($bank_info['User']['name']); ?>;
    var bank_name = <?php echo json_encode($bank_info['Bank']['bank_full']); ?>;
    var branch_name = <?php echo json_encode($bank_info['BankBranch']['branch_name_full']); ?>;
</script>

<?php echo $this->Html->script('bank/search'); ?>